package com.abner.design.patterns.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * 学院
 *   非叶子节点， 用于存储子部件， 在 Component 接口中实现 子部件的相关操作
 * @author abner
 */
public class College extends OrganizationComponent {

	List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();

	public College(String name, String des) {
		super(name, des);
	}

	/**
	 * 添加
	 * @param organizationComponent
	 */
	@Override
	protected void add(OrganizationComponent organizationComponent) {
		organizationComponents.add(organizationComponent);
	}

	/**
	 * 删除
	 * @param organizationComponent
	 */
	@Override
	protected void remove(OrganizationComponent organizationComponent) {
		organizationComponents.remove(organizationComponent);
	}

	/**
	 * 打印
	 */
	@Override
	protected void print() {
		System.out.println("--------------学院：" + getName() + "--------------");
		for (OrganizationComponent organizationComponent : organizationComponents) {
			organizationComponent.print();
		}
	}
}
